home *** CD-ROM | disk | FTP | other *** search
/ Racing Games (Spidla) / zavodni.iso / Fun Racing / src / FRGameLogo.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-06-19  |  4.2 KB  |  191 lines

  1.  
  2.  
  3. #ifndef FRGAMELOGO_H
  4. #define FRGAMELOGO_H
  5.  
  6. #include <Engine/Engine.h>
  7.  
  8. #include "FRCar.h"
  9.  
  10. class FRGameLogo
  11. {
  12. public:
  13.  
  14.     static void Start(void);
  15.  
  16. private:
  17.  
  18.     static void Initialize(void);
  19.     static void Cleanup(void);
  20.     static void Loop(void);
  21.  
  22.     static TESoundReference* ms_pTechno;
  23.     static TESoundReference* ms_pCrash;
  24.     static UInt32 ms_ulLogoStart;
  25.     static UInt32 ms_ulLogoState;
  26. };
  27.  
  28. class FRLoserGolf : public FRCar
  29. {
  30.     TERTTIDeclaration;
  31.  
  32. public:
  33.  
  34.     FRLoserGolf(TEVector &rCenter, Float fInitYRot)
  35.     {        TEOBoundingBox *pOBox = new TEOBoundingBox;
  36.         TEAABoundingBox BBox;
  37.         TEVector Min, Max;
  38.         TEEngine *pEngine = TEEngine::GetEngine();
  39.         TESoundManager* pSound = TESoundManager::GetSoundManager();
  40.         TEString Name;
  41.         
  42.         Name = "motor4.ogg";
  43.         m_pMotor = pSound->GetSound(Name);
  44.         Name = "brake.ogg";
  45.         m_pBraking = pSound->GetSound(Name);
  46.         Name = "horn1.ogg";
  47.         m_pHorn = pSound->GetSound(Name);
  48.         
  49.         m_fMass = 1100.0f;
  50.         m_fElasticity = 0.0f;
  51.         m_fFrictionFactor = 1.0f;
  52.  
  53.         m_fMaxRPM = 6000.0f;
  54.         m_fRotFactor = 0.7f;
  55.  
  56.         m_ulNumGears = 2;
  57.         m_aGears = new FRGearInfo[2];
  58.  
  59.         m_aGears[0].fRPMChange = 1500.0f;
  60.         m_aGears[0].fRPMTrans = -55.0f;
  61.         m_aGears[1].fRPMChange = 2000.0f;
  62.         m_aGears[1].fRPMTrans =  150.0f;
  63.  
  64.         m_Rotation = TEVector(0.0f, fInitYRot, 0.0f);
  65.  
  66.         m_pModelRef = TEModelManager::GetModelManager()->GetModel("crashgolf.tmf");
  67.         TEAssert(m_pModelRef);
  68.  
  69.         m_pModelRef->SetAnimation(0);
  70.         m_pModelRef->SetTimeScale(0);
  71.         m_pModelRef->SetLoopAnimation(true);
  72.         
  73.         BBox = m_pModelRef->GetModelBBox();
  74.         BBox.GetData(Min, Max);
  75.         m_CarSize = Max - Min;
  76.  
  77.         m_Center.m_fX = m_OldCenter.m_fX = rCenter.m_fX;
  78.         m_Center.m_fY = m_OldCenter.m_fY = m_fDeltaY = TEAbs(Min.m_fY);
  79.         m_Center.m_fZ = m_OldCenter.m_fZ = rCenter.m_fZ;
  80.  
  81.         pOBox->SetData(m_Center, Min, Max, m_Rotation);
  82.  
  83.         m_pBoundingVolume = pOBox;
  84.  
  85.         m_fFrontAxis = 0.0f;
  86.         m_fRearAxis = -31.0f;
  87.  
  88.         m_fWheelWidth = 5.5f;
  89.         m_fWheelMov = 3.5f;
  90.  
  91.         m_aLightPos[0] = TEVector(-7.25f, -1.00f,  24.5f);
  92.         m_aLightPos[1] = TEVector( 7.25f, -1.00f,  24.5f);
  93.         m_aLightPos[2] = TEVector(-7.50f,  1.25f, -24.5f);
  94.         m_aLightPos[3] = TEVector( 7.50f,  1.25f, -24.5f);
  95.  
  96.         m_fBrakeEfficiency = 1.0f;
  97.  
  98.         m_usNumExhaust = 1;
  99.         m_aExhaustPos[0] = TEVector(1.8f, -4.0f, -25.0f);
  100.  
  101.         UpdateVectors();
  102.  
  103.         TEVector Center = m_pBoundingVolume->GetCenter();
  104.         TEVector Tmp = Center + m_aExhaustPos[0].m_fX * m_Right +
  105.             m_aExhaustPos[0].m_fY * m_Up + m_aExhaustPos[0].m_fZ * m_Forward;
  106.         m_aExhaust[0] = new TEParticleFX(Tmp, 2, 4, 1.2f, 0, 0, 0, m_Up, 250, 1000,
  107.             255, 1.0f, true, false);
  108.         m_aExhaust[0]->SetColor(255, 255, 255);
  109.         pEngine->AddParticleSystem(m_aExhaust[0]);
  110.  
  111.         if(m_pMotor != NULL)
  112.             m_pMotor->Play3D(m_Center, m_Velocity, TESOUND_LOOP, 1.0f);
  113.  
  114.         m_bClip = false;
  115.     }
  116.  
  117.     void Brake(void)
  118.     {
  119.         m_bClip = false;
  120.         m_bApplyGravity = false;
  121.         m_fPedal = -1.0f;
  122.         m_pModelRef->SetLoopAnimation(false);
  123.         m_pBraking->Play3D(m_Center, m_Velocity, 0, 1.0f);
  124.     }
  125.  
  126.     void Stop(void)
  127.     {
  128.         m_bClip = false;
  129.         m_bApplyGravity = false;
  130.         m_fPedal = 0;
  131.         m_fCurrentRPM = 0;
  132.         m_lCurrentGear = -1;
  133.         m_Acceleration = m_Velocity = TEVector(0,0,0);
  134.         m_pBraking->Stop();
  135.         Update(1, TEEngine::GetEngine());
  136.     }
  137. };
  138.  
  139. class FRCloakLogo : public TEEngineObject
  140. {
  141.     TERTTIDeclaration;
  142.  
  143. public:
  144.  
  145.     FRCloakLogo()
  146.     {
  147.         TEString Pak = "logos";
  148.         TEString Name = "fr2";
  149.  
  150.         m_bClip = false;
  151.         m_bTransparency = true;
  152.  
  153.         m_ulLifetime = 0;
  154.         m_pTex = TETextureManager::GetTextureManager()->GetTexture(Name, Pak, false);
  155.     }
  156.  
  157.     ~FRCloakLogo()
  158.     {
  159.         SafeDelete(m_pTex);
  160.     }
  161.  
  162. protected:
  163.  
  164.     void Animate(UInt32 ulDeltaT, TEEngine* pEngine)
  165.     {
  166.         m_ulLifetime += ulDeltaT;
  167.     }
  168.  
  169.     void Render(TERenderer* pRender, TECamera* pCam)
  170.     {
  171.         UInt32 ulAlpha = m_ulLifetime / 20;
  172.  
  173.         if(ulAlpha > 192)
  174.             ulAlpha = 192;
  175.  
  176.         pRender->SetAmbient(255, 255, 255, (UChar) ulAlpha);
  177.         pRender->EnableBlending();
  178.         pRender->SetBlendingState(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
  179.         pRender->SetTexture(m_pTex);
  180.         pRender->DrawRectanglef(0.15f, 0.2f, 0.85f, 0.8f);
  181.         pRender->DisableBlending();
  182.     }
  183.  
  184. private:
  185.  
  186.     UInt32 m_ulLifetime;
  187.     TETextureReference* m_pTex;
  188. };
  189.  
  190.  
  191. #endif